<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript">

    $(function () {
        toggleOptional();
        $('#area').hide();
        $('#show-btn').show();
        $('#hide-btn').hide();
        $('#planServeyor').hide();

        $('#planNumber').bind('blur', function () {
            showHidePlanInfo($('#planNumber').val());
        });
        showHidePlanInfo($('#planNumber').val());

        disablePaste(new Array(
                'hectareId',
                'acreId',
                'roodsId',
                'perchesId'
                ));
    });

    function showHidePlanInfo(planNo) {
        if (planNo.length > 0) {
            $('#planServeyor').show();
        } else {
            $('#planServeyor').hide();
        }
    }

    function disableLandInformation() {
        var fields = new Array(
                'districtId',
                //'dsDivisionId',
                //'gnDivisionId',
                //'localAuthorityId',
                'village',
                //'nameOfTheLand',
                'planNumber',
                'lotNumber',
                'planDate',
            //'parentLandRefNumber',
                'hectareId',
                'acreId',
                'roodsId',
                'perchesId',
                'northBoundary',
                'northEastBoundary',
                'eastBoundary',
                'southEastBoundary',
                'southBoundary',
                'southWestBoundary',
                'westBoundary',
                'northWestBoundary',
                'northBoundaryType',
                'northEastBoundaryType',
                'eastBoundaryType',
                'southEastBoundaryType',
                'southBoundaryType',
                'southWestBoundaryType',
                'westBoundaryType',
                'northWestBoundaryType',
                'landComment',
                'geologicalTypeId',
                //'verifiedByBeneficiarytrue',
                //'verifiedByBeneficiaryfalse',
                //'areaInWordId',
                'surveyor',
                //'purpose',
                'alienationMethodSelectedList-1',
                'alienationMethodSelectedList-2',
                'alienationMethodSelectedList-3',
                'alienationMethodSelectedList-4',
                'alienationMethodSelectedList-5',
                'alienationMethodSelectedList-6',
                'alienationMethodSelectedList-7'
                );
        disableFields(fields);
    }

   /* $(function () {

        $("#geoDetails").hide();
        if ($('#approvalState').val() == 'PENDING' && (  (  ($('#userRole').val() != 'SC') )  ) ){
            disableLandInformation();
            $("#geoDetails").show();
            //todo: Show map and gis info

        }

    });*/

    function toggleOptional() {
        $('.optional-boundary').toggle();
        $('#show-btn').toggle();
        $('#hide-btn').toggle();
    }

    $(document).ready(function () {
        changeHectareKml();
    });

    function searchLand() {
        var landId = $('#parentSerialNumber').val();
        var url = '${pageContext.request.contextPath}' + '/viewDetailLandReportByAttachLand.do?landId=' + landId + ' ';

        myWindow = window.open(url, '', 'width=980,height=500,scrollbars=yes');
        myWindow.focus();
    }

    ////////////////////////////////////////////////////////////////////////////////////
</script>
<fieldset>
<table class="width-100">
    <tr>
        <s:if test="land.mode.ordinal() == 1 || land.mode.ordinal() == 2">

            <td><s:label value="%{getText('slmsSerialNumber.label')}"/></td>
            <td colspan="3">
                <%--<s:textfield id="referenceNumber" cssClass="width-200-px" name="tempRefNo"--%>
                                         <%--disabled="true" value="%{land.id}"/>--%>
            </td>

        </s:if>
    </tr>
    <tr>
        <s:if test="land.mode.ordinal() == 2">
            <td><s:label value="%{getText('parentSerialNumber.label')}"/></td>
            <td>
                <%--<s:textfield id="parentSerialNumber" cssClass="width-200-px" name="land.parentLand.id"--%>
                             <%--disabled="true"/>--%>
            </td>

            <td><input type="button" id="show_landList" value="View"
                       onclick="searchLand()"/></td>

        </s:if>
    </tr>
    <tr>
        <s:if test="#session.userGroup =='sc'">

            <td class="left-align"><s:label value="%{getText('district.label')}"/></td>
            <td><s:select list="districtList" name="land.district.id" headerKey="0" headerValue="%{getText('select.label')}"
                          id="districtId"/></td>

            <%--<td class="left-align"><s:label value="%{getText('ds_division.label')}"/></td>--%>

        </s:if>
        <s:else>
            <td><s:label value="%{getText('district.label')}"/></td>
            <td>
                <s:textfield id="districtId" name="districtName" cssClass="width-200-px" disabled="true"/>
            </td>

            <%--<td><s:label value="%{getText('ds_division.label')}"/></td>
            <td><s:textfield id="dsDivisionId" name="dsDivisionName" cssClass="width-200-px" disabled="true"/></td>--%>
        </s:else>

        <td class="left-align"><s:label value="Railway Track"/></td>
        <td>
            <s:select name="land.railwayTrack.id" id="railwayTrackId" headerKey="0" headerValue="%{getText('select.label')}"
                      list="railwayTrackList" cssClass="width-200-px"/>
            <%--TODO: Replace List by railwayTrack List--%>
        </td>
    </tr>
    <tr>
        <%--<td><s:label value="%{getText('gn_division.label')}"/><span class="mandatory-field"></span></td>--%>
        <td><s:label value="District Engineer Zone"/><span class="mandatory-field"></span></td>
        <td>
            <s:if test="viewMode">
                <%--<s:textfield id="districtEngineerZoneId" name="land.districtEngineerZone.id" cssClass="width-200-px"/>--%>
            </s:if>
            <s:else>
                <s:select id="1" name="land.districtEngineerZone.id" list="districtEngineerZoneList" headerKey="0"
                          headerValue="%{getText('select.label')}" cssClass="width-200-px"/>
                <%--TODO: Replace List by districtEngineerZone List--%>
            </s:else>
        </td>
        <%--<td><s:label value="%{getText('local_authority.label')}"/></td>--%>
            <td><s:label value="IPW Zone"/></td>
        <td>
            <s:if test="viewMode">
                <%--<s:textfield id="1" name="land.ipwZone.id" cssClass="width-200-px"/>--%>
            </s:if>
            <s:else>
                <s:select id="1" name="land.ipwZone.id" list="IPWZoneList"
                          cssClass="width-200-px" headerKey="0" headerValue="%{getText('select.label')}"/>
                <%--TODO: Replace List by IPWZone List--%>
            </s:else>
        </td>
    </tr>

    <tr>
        <%--<td><s:label value="%{getText('gn_division.label')}"/><span class="mandatory-field"></span></td>--%>
        <td><s:label value="Railway Protection Zone"/><span class="mandatory-field"></span></td>
        <td>
            <s:if test="viewMode">
                <%--<s:textfield id="gnDivisionId" name="land.railwayProtectionZone.id" cssClass="width-200-px"/>--%>
            </s:if>
            <s:else>
                <s:select id="1" name="land.railwayProtectionZone.id" list="railwayProtectionZoneList" headerKey="0"
                          headerValue="%{getText('select.label')}" cssClass="width-200-px"/>
                <%--TODO: Replace List by railwayProtectionZone List--%>
            </s:else>
        </td>
        <%--<td><s:label value="%{getText('local_authority.label')}"/></td>--%>
        <td><s:label value="Nearest Railway Station"/></td>
        <td>
            <s:if test="viewMode">
                <s:textfield id="1" name="land.nearestRailwayStation.id" cssClass="width-200-px"/>
            </s:if>
            <s:else>
                <s:select id="localAuthorityId" name="land.nearestRailwayStation.id" list="railwayStationList"
                          cssClass="width-200-px" headerKey="0" headerValue="%{getText('select.label')}"/>
                <%--TODO: Replace List by RailwayStation List--%>
            </s:else>
        </td>
    </tr>
    <%--  <tr>
        <td colspan="4">
            <s:select name="land.mode"
               listValue="toString()" headerKey=""
               headerValue="INITIAL" list="modesAsList" />
        </td>
    </tr>--%>
    <tr>
        <%--<td><s:label value="%{getText('name_of_the_land.label')}"/><span class="mandatory-field"></span></td>--%>
        <td><s:label value="File No"/><span class="mandatory-field"></span></td>
        <td><s:textfield name="land.landFileNumber" id="fileNo" cssClass="width-200-px"/></td>
        <td><s:label value="%{getText('village.label')}"/></td>
        <td><s:textfield name="land.village" id="village" cssClass="width-200-px"/></td>
    </tr>
    <tr>
        <td><s:label value="%{getText('plan_no.label')}"/></td>
        <td><s:textfield name="land.planNumber" id="planNumber" cssStyle="width: 200px;"/></td>
        <td><s:label value="%{getText('lot_no.label')}"/></td>
        <td><s:textfield name="land.lotNumber" id="lotNumber" cssStyle="width: 200px;"/></td>
    </tr>
    <tr id="planServeyor">
        <td><s:label value="%{getText('surveyor.label')}"/></td>
        <s:if test="land.mode.ordinal() == 1">
            <td><s:textfield name="land.surveyor" id="surveyor"
                             cssClass="width-200-px"/></td>
        </s:if>
        <s:else>
            <td><s:textfield name="land.surveyor" id="surveyor" value="%{getText('servey_general.label')}"
                             cssClass="width-200-px"/></td>
        </s:else>

        <td><s:label value="%{getText('plan_date.label')}"/> <s:label value="%{getText('date_format.label')}"
                                                                      cssClass="date-format"/></td>
        <td><s:textfield id="planDate" name="land.planDate" cssClass="width-200-px"/></td>
    </tr>
    <tr>
        <td><s:label value="%{getText('geological_type.label')}"/></td>
        <td class="left-align" colspan="3">
            <s:if test="viewMode">
                <s:textfield id="geologicalTypeId" name="land.geologicalType.name" cssClass="width-200-px"/>
            </s:if>
            <s:else>
                <s:select id="geologicalTypeId" name="land.geologicalType.id"
                          list="geologicalTypeList" headerKey="0"
                          headerValue="%{getText('select.label')}" cssClass="width-200-px"/>
            </s:else>
        </td>
    </tr>

    <%--<s:if test="land.mode.ordinal() == 1 || land.mode.ordinal() == 2">--%>
        <%--<s:if test="land.geoParcelCode != null">--%>
            <%--<tr>--%>
                <%--<td><s:label value="%{getText('geoParcelCode.label')}"/></td>--%>
                <%--<td colspan="3"><s:label name="land.getGeoParcelCode()"--%>
                        <%--/></td>--%>
            <%--</tr>--%>
        <%--</s:if>--%>
    <%--</s:if>--%>
    <tr>
        <td><s:label value="Land Location From"/></td>
        <td class="left-align">
            <s:textfield id="geologicalTypeId" name="land.landLocation.fromMile" cssClass="width-200-px"/>
        </td>
        <td><s:label value="Land Location To"/></td>
        <td class="left-align">
            <s:textfield id="geologicalTypeId" name="land.landLocation.toMile" cssClass="width-200-px"/>
        </td>
    </tr>
</table>
<%--<table id="geoDetails">
    <s:if test="land.mode.ordinal() == 1 || land.mode.ordinal() == 2">

        <tr id="area">
            <td><s:label value="Area"/></td>
            <td colspan="3"><s:textfield id="kmlArea" cssClass="width-200-px" name="land.kmlLandArea"
                                         readonly="true"/></td>
        </tr>
        <tr>
            <td><s:label value="%{getText('kml_land_extent.label')}"/></td>
            <td colspan="3">
                <table class="width-100">
                    <tr>
                        <td><s:label value="%{getText('hectare.label')}"/></td>
                        <td colspan="5"><s:textfield id="kmlhectareId" name="kmlhectare" cssStyle="width: 80px;"
                                                     readonly="true"/></td>
                    </tr>
                    <tr>
                        <td><s:label value="%{getText('acre.label')}"/></td>
                        <td><s:textfield id="kmlacreId" name="kmlacre" cssStyle="width: 80px;" readonly="true"/></td>
                        <td><s:label value="%{getText('roods.label')}"/></td>
                        <td><s:textfield id="kmlroodsId" name="kmlroods" cssStyle="width: 80px;" readonly="true"/></td>
                        <td><s:label value="%{getText('perches.label')}"/></td>
                        <td><s:textfield id="kmlperchesId" name="kmlperches" cssStyle="width: 80px;"
                                         readonly="true"/></td>
                    </tr>
                </table>
            </td>
        </tr>

        <s:include value="map.jsp"/>

    </s:if>
</table>--%>
<table>
    <tr>
        <td><s:label value="%{getText('extent_of_the_land.label')}"/></td>
        <td colspan="3">
            <table class="width-100">
                <tr>
                    <td><s:label value="%{getText('hectare.label')}"/></td>
                    <td colspan="3"><s:textfield id="hectareId" name="hectare" cssStyle="width: 80px;"
                                                 onKeyPress="return numbersonly(event,true)"/></td>

                </tr>

                <tr>
                    <td><s:label value="%{getText('acre.label')}"/></td>
                    <td><s:textfield id="acreId" name="acre" cssStyle="width: 80px;"
                                     onKeyPress="return numbersonly(event,true)"/></td>
                    <td><s:label value="%{getText('roods.label')}"/></td>
                    <td><s:textfield id="roodsId" name="roods" cssStyle="width: 80px;"
                                     onKeyPress="return numbersonly(event,true)"/></td>
                    <td><s:label value="%{getText('perches.label')}"/></td>
                    <td><s:textfield id="perchesId" name="perches" cssStyle="width: 80px;"
                                     onKeyPress="return numbersonly(event,true)"/></td>
                </tr>

                <tr>
                    <td><s:label value="%{getText('hectare_in_word.label')}"/></td>
                    <td colspan="3">
                        <%--<s:textarea id="areaInWordId" name="land.areaInWord" cssClass="width-200-px"--%>
                                                <%--rows="2"/>--%>
                    </td>
                </tr>

            </table>
        </td>
    </tr>
    <tr>
        <td><s:label value="%{getText('boundaries.label')}"/></td>
        <td colspan="3">
            <table class="width-100">
                <tr>
                    <td class="width-120-px"><s:label value="%{getText('north.label')}"/></td>
                    <td><s:textarea id="northBoundary" name="land.northBoundary" cssClass="width-250-px" rows="1"/></td>
                    <s:if test="viewMode">
                        <td><s:textfield name="land.northBoundaryType.id" cssClass="width-150-px"
                                         id="northBoundaryType"/></td>
                    </s:if>
                    <s:else>
                        <td><s:select name="land.northBoundaryType.id" cssClass="width-150-px" id="northBoundaryType"
                                      list="boundaryTypeList" headerKey="0"
                                      headerValue="%{getText('select.label')}"/></td>
                    </s:else>
                </tr>
                <tr>
                    <td><s:label value="%{getText('east.label')}"/></td>
                    <td><s:textarea id="eastBoundary" name="land.eastBoundary" cssClass="width-250-px" rows="1"/></td>
                    <s:if test="viewMode">
                        <td><s:textfield name="land.eastBoundaryType.id" cssClass="width-150-px"
                                         id="eastBoundaryType"/></td>
                    </s:if>
                    <s:else>
                        <td><s:select name="land.eastBoundaryType.id" cssClass="width-150-px" id="eastBoundaryType"
                                      list="boundaryTypeList" headerKey="0"
                                      headerValue="%{getText('select.label')}"/></td>
                    </s:else>
                </tr>
                <tr>
                    <td><s:label value="%{getText('south.label')}"/></td>
                    <td><s:textarea id="southBoundary" name="land.southBoundary" cssClass="width-250-px" rows="1"/></td>
                    <s:if test="viewMode">
                        <td><s:textfield name="land.southBoundaryType.id" cssClass="width-150-px"
                                         id="southBoundaryType"/></td>
                    </s:if>
                    <s:else>
                        <td><s:select name="land.southBoundaryType.id" cssClass="width-150-px" id="southBoundaryType"
                                      list="boundaryTypeList" headerKey="0"
                                      headerValue="%{getText('select.label')}"/></td>
                    </s:else>
                </tr>
                <tr>
                    <td><s:label value="%{getText('west.label')}"/></td>
                    <td><s:textarea id="westBoundary" name="land.westBoundary" cssClass="width-250-px" rows="1"/></td>
                    <s:if test="viewMode">
                        <td><s:textfield name="land.westBoundaryType.id" cssClass="width-150-px"
                                         id="westBoundaryType"/></td>
                    </s:if>
                    <s:else>
                        <td><s:select name="land.westBoundaryType.id" cssClass="width-150-px" id="westBoundaryType"
                                      list="boundaryTypeList" headerKey="0"
                                      headerValue="%{getText('select.label')}"/></td>
                    </s:else>
                </tr>
                <s:if test="!viewMode">
                    <tr class="optional-boundary">
                        <td><s:label value="%{getText('north_east.label')}"/></td>
                        <td><s:textarea id="northEastBoundary" name="land.northEastBoundary" cssClass="width-250-px"
                                        rows="1"/></td>
                        <td><s:select name="land.northEastBoundaryType.id" cssClass="width-150-px"
                                      id="northEastBoundaryType"
                                      list="boundaryTypeList" headerKey="0"
                                      headerValue="%{getText('select.label')}"/></td>
                    </tr>
                    <tr class="optional-boundary">
                        <td><s:label value="%{getText('south_east.label')}"/></td>
                        <td><s:textarea id="southEastBoundary" name="land.southEastBoundary" cssClass="width-250-px"
                                        rows="1"/></td>
                        <td><s:select name="land.southEastBoundaryType.id" cssClass="width-150-px"
                                      id="southEastBoundaryType"
                                      list="boundaryTypeList" headerKey="0"
                                      headerValue="%{getText('select.label')}"/></td>
                    </tr>
                    <tr class="optional-boundary">
                        <td><s:label value="%{getText('south_west.label')}"/></td>
                        <td><s:textarea id="southWestBoundary" name="land.southWestBoundary" cssClass="width-250-px"
                                        rows="1"/></td>
                        <td><s:select name="land.southWestBoundaryType.id" cssClass="width-150-px"
                                      id="southWestBoundaryType"
                                      list="boundaryTypeList" headerKey="0"
                                      headerValue="%{getText('select.label')}"/></td>
                    </tr>
                    <tr class="optional-boundary">
                        <td><s:label value="%{getText('north_west.label')}"/></td>
                        <td><s:textarea id="northWestBoundary" name="land.northWestBoundary" cssClass="width-250-px"
                                        rows="1"/></td>
                        <td><s:select name="land.northWestBoundaryType.id" cssClass="width-150-px"
                                      id="northWestBoundaryType"
                                      list="boundaryTypeList" headerKey="0"
                                      headerValue="%{getText('select.label')}"/></td>
                    </tr>
                </s:if>
                <tr align="right">
                    <td colspan="2"></td>
                    <td>
                        <s:submit onclick="toggleOptional(); return false;" id="show-btn"
                                  value="%{getText('show_other_boundaries.label')}"/>
                        <s:submit onclick="toggleOptional(); return false;" id="hide-btn"
                                  value="%{getText('hide_other_boundaries.label')}"/>
                    </td>
                </tr>

            </table>
        </td>
    </tr>

    <tr>
        <td><s:label value="%{getText('comment_about_land.label')}"/></td>
        <td colspan="3">
            <s:textarea id="landComment" cssClass="width-595-px"
                                    name="land.landVisitComment" rows="5"/>
        </td>
    </tr>


</table>

<%--<div id="alienationMethodsDivID">--%>
    <%--<table>--%>
        <%--<s:if test="land.mode.ordinal() == 1 || land.mode.ordinal() == 2">--%>
            <%--<tr><h3><s:label value="%{getText('association_detail.label')}"/></h3></tr>--%>
            <%--<tr>--%>
                <%--<td><s:label value="%{getText('alienation_methods.label')}"/></td>--%>
                <%--<td>--%>
                    <%--&lt;%&ndash;<s:checkboxlist id="alienationMethodSetId" list="alienationMethodSet"&ndash;%&gt;--%>
                                    <%--&lt;%&ndash;name="alienationMethodSelectedList"&ndash;%&gt;--%>
                                    <%--&lt;%&ndash;value="amSelectedList"&ndash;%&gt;--%>
                                    <%--&lt;%&ndash;theme="checkbox-theme"/>&ndash;%&gt;--%>
                <%--</td>--%>


            <%--</tr>--%>

            <%--<tr>--%>
                <%--<td class="left-align"><s:label value="%{getText('association_purpose.label')}"/> :</td>--%>
                <%--<td class="left-align">--%>
                    <%--&lt;%&ndash;<s:textarea id="purpose" cssClass="width-450-px"&ndash;%&gt;--%>
                                                   <%--&lt;%&ndash;name="landAssociation.purpose" rows="3"/>&ndash;%&gt;--%>
                <%--</td>--%>
            <%--</tr>--%>
        <%--</s:if>--%>
    <%--</table>--%>
<%--</div>--%>
<s:if test="!viewMode">
    <%--<s:include value="../documentUpload.jsp"/>--%>
</s:if>
</fieldset>
<s:hidden id="landId" name="land.id"/>
<s:hidden name="land.version"/>
<s:hidden name="land.alienationState"/>
<s:hidden id="landMode" name="land.mode"/>
<s:hidden name="land.parentId"/>
<s:hidden id="initRecord" name="land.initialRecordId"/>
<s:hidden name="land.comment"/>
<s:hidden id="approvalState" name="land.approvalState"/>
<s:hidden id="dsDivisionId" name="dsDivisionId"/>
<s:hidden id="landExtent" name="land.landExtent"/>
<s:hidden id="kmlLandArea" name="land.kmlLandArea" disabled="true"/>

<s:hidden id="pls_select_gnDivision" value="%{getText('pls_select_gnDivision.label')}"/>
